package com.date.entity;


import java.util.Date;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;

public class Test {

		/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		String str="FROM Student";
		AnnotationConfiguration afg=new AnnotationConfiguration();
		afg.configure();
		SessionFactory sf=afg.buildSessionFactory();
		Session ses=sf.openSession();
		
		Transaction tx=ses.beginTransaction();
		Student std=new Student();
		
		/*std.setAge(20);
		std.setDob(new Date(1251990));
		std.setName("Vijay");
		std.setStuId(12);

		ses.save(std);
*/		
		Student s1=(Student) ses.load(Student.class, 13);
		System.out.println("S1:"+s1);
		Query q=ses.createQuery(str);
		@SuppressWarnings("unchecked")
		List<Student> li=q.list();
		
		for(Student s:li)
			System.out.println("StudentDetails:"+s);
		tx.commit();
		
		System.out.println("Object is saved successfully.....");
	}

}
